package com.ymatou.app.api.service;

import org.json.JSONArray;
import org.json.JSONObject;

import com.ymt.base.YmatouBaseCall;
import com.ymttest.utils.EnvSetup;

public class SimilarProdCall extends YmatouBaseCall{
	
	private static String open_url = "api/prod/similarprod";

	public SimilarProdCall() {
		super(EnvSetup.getSystemUrl("api_app"), open_url, "GET", "PARAM");
	}
	
	@Override
	public void addDefHeader() {
		client.addHeader("Accept", "text/xml,text/javascript,text/html,application/json");
		client.addHeader("Content-Type", "application/json; charset=UTF-8");
	}
	
	/**
	 * 获取total
	 * 
	 * @return
	 */
	public int getTotal() {
		int total = 0;
		try {
			total = new JSONObject(getReturnData()).getInt("total");
		} catch (Exception e) {
			e.printStackTrace();
		}
		return total;
	}
	
	/**
	 * 获取list
	 * 
	 * @return
	 */
	public JSONArray getList() {
		JSONArray list = null;
		
		try {
			list = new JSONObject(getReturnData()).getJSONArray("list");
		} catch (Exception e) {
			e.printStackTrace();
		}
		
		return list;
	}
	
	/**
	 * 获取status
	 * 
	 * @return
	 */
	public String getStatus() {
		String status = "";
		
		try {
			status = new JSONObject(getReturnData()).getString("status");
		} catch(Exception e) {
			e.printStackTrace();
		}
		
		return status;
	}
	
	/**
	 * 获取msg
	 * 
	 * @return
	 */
	public String getMsg() {
		String msg = "";
		
		try {
			msg = new JSONObject(getReturnData()).getString("msg");
		} catch(Exception e) {
			e.printStackTrace();
		}
		
		return msg;
	}
}
